using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
	public partial class Geo_CountryComponent
    {
		//
		// TODO: Add constructor logic here
		//


        /// <summary>
        /// Returns the identity of a state given the abbreviation
        /// </summary>
        /// <returns>AdminsitrativeDivisionId</returns>
        public int GetCountryIdWCountryName(string countryName)
        {
            PlacementManager.DAL.Geo_Country_DAL o = new PlacementManager.DAL.Geo_Country_DAL();
            o.CountryName = countryName;
            return o.GetCountryIdWCountryName();
        }

        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public List<Geo_Country> SelectAllWDisplay(string sortExpression)
        {
            List<Geo_Country> listGeo_Country = new List<Geo_Country>();
            PlacementManager.DAL.Geo_Country_DAL o = new PlacementManager.DAL.Geo_Country_DAL();

            DataSet ds = o.SelectAllWDisplay();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listGeo_Country.Add(new Geo_Country((int)row["CountryID"], (string)row["CountryName"], (string)row["CountryCode"], (string)row["SubDivisionSingularName"], (string)row["SubDivisionPluralName"], (bool)row["Display"]));
            }

            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }

            listGeo_Country.Sort(new Geo_CountryComparer(sortExpression));
            return listGeo_Country;
        }
	}
}
